import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'home',
      component: HomeView,
      meta: { title: '首页' },
    },
    {
      path: '/three',
      name: 'three-demo',
      meta: { title: '3D模型' },
      children: [
        {
          path: '/box',
          name: 'box',
          component: () => import('../components/Box.vue'),
          meta: { title: '立方体旋转加背景' },
        },
        {
          path: '/camera',
          name: 'camera',
          component: () => import('../components/CameraChange.vue'),
          meta: { title: '相机运动' },
        },
        {
          path: '/orbit',
          name: 'orbit',
          component: () => import('../components/OrbitControls.vue'),
          meta: { title: '轨道编辑器' },
        },
        {
          path: '/buff',
          name: 'buff',
          component: () => import('../components/BuffGeometry.vue'),
          meta: { title: '几何体的构成原理' },
        },
        {
          path: '/material',
          name: 'material',
          component: () => import('../components/Material.vue'),
          meta: { title: '几何体的材质' },
        },
        {
          path: '/light',
          name: 'light',
          component: () => import('../components/LightAndShadow.vue'),
          meta: { title: '光源和阴影' },
        },
        {
          path: '/raycaster',
          name: 'raycaster',
          component: () => import('../components/Raycaster.vue'),
          meta: { title: '射线检测' },
        },
        {
          path: '/mouseRaycaster',
          name: 'mouseRaycaster',
          component: () => import('../components/MouseRaycaster.vue'),
          meta: { title: '鼠标射线检测' },
        },
        {
          path: '/physicalMotion',
          name: 'physicalMotion',
          component: () => import('../components/PhysicalMotion.vue'),
          meta: { title: '物理运动' },
        },
        {
          path: '/physicalMotion2',
          name: 'physicalMotion2',
          component: () => import('../components/PhysicalMotion2.vue'),
          meta: { title: '物理运动2' },
        },
        {
          path: '/glbLoader',
          name: 'glbLoader',
          component: () => import('../components/GLBLoader.vue'),
          meta: { title: 'GLB加载器' },
        },
        {
          path: '/threeD',
          name: 'threeD',
          component: () => import('../components/ThreeD.vue'),
          meta: { title: '3D模型看房' },
        },
      ],
    },
    {
      path: '/about',
      name: 'about',
      component: () => import('../views/AboutView.vue'),
      meta: { title: '关于' },
    },
    {
      path: '/:pathMatch(.*)*',
      name: 'not-found',
      component: () => import('../views/NotFound.vue'),
      meta: {
        title: '404',
        hidden: true,
      },
    },
  ],
})

export default router
